/**
 * 
 */
package cn.g31010.sip.pojo;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author user
 *
 */
public class Room implements java.io.Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3617904017086800253L;
	private String id;
	private String name;
	private String passwd;
	private User owner;
	private Gateway gateway;
	private Classes classes;
	private Config config;
	private String status;
	
	private List<User> admins=new ArrayList<User>();
	
	private List<User> whiteMembers=new ArrayList<User>();
	
	private List<User> blackMemebers=new ArrayList<User>();

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPasswd() {
		return this.passwd;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}

	public User getOwner() {
		return this.owner;
	}

	public void setOwner(User owner) {
		this.owner = owner;
	}

	public Gateway getGateway() {
		return this.gateway;
	}

	public void setGateway(Gateway gateway) {
		this.gateway = gateway;
	}

	public Config getConfig() {
		return this.config;
	}

	public void setConfig(Config config) {
		this.config = config;
	}

	public List<User> getAdmins() {
		return this.admins;
	}

	public void setAdmins(List<User> admins) {
		this.admins = admins;
	}

	public List<User> getWhiteMembers() {
		return this.whiteMembers;
	}

	public void setWhiteMembers(List<User> whiteMembers) {
		this.whiteMembers = whiteMembers;
	}

	public List<User> getBlackMemebers() {
		return this.blackMemebers;
	}

	public void setBlackMemebers(List<User> blackMemebers) {
		this.blackMemebers = blackMemebers;
	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
		return result;
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Room other = (Room) obj;
		if (this.id == null) {
			if (other.id != null)
				return false;
		} else if (!this.id.equals(other.id))
			return false;
		return true;
	}
	
	public String toString() {
		JSONObject jso=new JSONObject();
		try {
			jso.put("id", id);
			jso.put("name", name);
			jso.put("passwd", passwd);
			jso.put("owner", owner);
			jso.put("gateway", gateway);
			jso.put("classes", classes);
			jso.put("status", status);
			jso.put("admins", admins.size());
			jso.put("whiteMembers", whiteMembers.size());
			jso.put("blackMemebers", blackMemebers.size());
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return jso.toString();
	}

	public Classes getClasses() {
		return this.classes;
	}

	public void setClasses(Classes classes) {
		this.classes = classes;
	}
	
}
